using Exoa.Cameras.Demos;
using UnityEngine;
using UnityEngine.UI;

public class BusBiaoQian : BiaoQianCreat
{
    public string TimeTable= "摆渡车时间表";
    GameObject animator;
    GameObject ZuDang;
    public override void OnCreat()
    {
        animator = GameObject.Find(TimeTable);
        if (animator == null)
        {
            Debug.LogError("标签名称为" + TimeTable + "的物体不存在");
        }
        ZuDang = GameObject.Find("阻挡");
        if (ZuDang == null)
        {
            Debug.LogError("标签名称为阻挡的物体不存在");
        }
        if (animator != null)
            animator.GetComponentInChildren<Button>().onClick.AddListener(() =>
            {
                animator.GetComponent<Animator>().SetBool("isOn", false);
                this.GetComponent<FocusOnClick>().Shijiao();
                ZuDang.GetComponent<Image>().raycastTarget = false;

            });
    }
    /// <summary>
    /// 重写父类的点击函数
    /// </summary>
    public override void OnClickFunc()
    {
        if (animator == null|| ZuDang == null)
            return;
 
        animator.GetComponent<Animator>().SetBool("isOn", true);
        ZuDang.GetComponent<Image>().raycastTarget = true;

    }
}
